define(function(require, exports, module) {
	var acore = require('../../core/common');
	var nativeUI = require('../../core/nativeUI');
	//	acore.setRem();
	var vm = new Vue({
		el: '#app',
		data: {
			dataList: [],
			selectedTabsList: [],
			broadcastList: [],
			city: "",
			cityNum: 206,
			latitude: "39.915",
			longitude: "116.404",
			CityList: [],
			servicePersonList:[],
			isShowService: false,
			foodsType: 1,
			isShowRedPacket: false,
			currentLon: "",
			currentLat: "",
			dataMapList:[],
			mapZoom: 6,
			mapZommNUm: 0,
			isFirstInitMap: true,
			page: 0,
			isShowPop: false,
			isShowNewLocation: false,
			isShowTrail: false,
			isShowCarOwner: false,
			isShowTransportationCardInquiry: false,
			isShowfakeFalseCar:false,
			carNumber: "",
			carNumberTrajectory: "",
			startTime: "",
			endTime: "",
			carNumberOwner: "",
			ownerName: "",
			ownerPhone: "",
			trajectoryQueryvclN: "",
			isShowTrajectoryQuery: "",
			isShowTransportationCardInquiry: "",
			isShowCheckAreaByVclNo: "",
			checkAreaByVclNovclN: "",
			configInfo:[],
			UserMoney: "余额",
			PayMode: {},
			OrderType: 6,
			PayOrderInfo:{},
			bdtype: "",
			isCar: false,
			carcityno: "",
			carcityname: ""
		},
		mounted: function() {
			var that = this;
			// 显示红包
			if(localStorage.getItem("registerSucc")) { 
			    that.isShowRedPacket = true;
			}
			localStorage.removeItem("registerSucc");
			that.refreshLoginToken();
			if(JSON.parse(localStorage.getItem("selectedTabsList"))) {
				that.selectedTabsList = JSON.parse(localStorage.getItem("selectedTabsList"));
				that.AppendModular();
			} else {
				that.selectedTabsList = {
					"ServiceMain": {
						"title": "需求发布",
						"src": "../../images/icon_menuDemand.png",
						"miniconUrl":"../../images/minicon_MenuDemand.png",
						"ViewType":"2",
						"OpenViewUrl":"../oilLife/ServiceMain.html"
					},"shortcutKey_jzdj": {
						"title": "精准对接",
						"src": "../../images/ic_home_func_accurate_connect.png",
						"miniconUrl":"../../images/minicon_jzdj.png",
						"ViewType":"2",
						"OpenViewUrl":"../menu/shortcutKey_jzdj.html"
					},"oil_cicle": {
						"title": "全国社群",
						"src": "../../images/icon_MenuCommunity.png",
						"miniconUrl":"../../images/minicon_MenuCommunity.png",
						"ViewType":"1",
						"OpenViewUrl":"oil_cicle"
					},"main_jcpd": {
						"title": "集采拼单",
						"src": "../../images/icon_MenuCollage.png",
						"miniconUrl":"../../images/minicon_MenuCollage.png",
						"ViewType":"2",
						"OpenViewUrl":"../menu/main_jcpd.html"
					},"OfferMain": {
						"title": "实时报价",
						"src": "../../images/icon_MenuOffer.png",
						"miniconUrl":"../../images/minicon_MenuOffer.png",
						"ViewType":"2",
						"OpenViewUrl":"../main/OfferMain.html"
					},"agricultural_platform": {
						"title": "涉农平台",
						"src": "../../images/icon_menuPlatform.png",
						"miniconUrl":"../../images/minicon_MenuPlatform.png",
						"ViewType":"2",
						"OpenViewUrl":"../main/agricultural_platform.html"
					},"oil_life": {
						"title": "多多知道",
						"src": "../../images/icon_MenuKnow.png",
						"miniconUrl":"../../images/minicon_MenuKnow.png",
						"ViewType":"1",
						"OpenViewUrl":"oil_life"
					}
				};
				that.AppendModular();
			}
			mui.init();
			mui.plusReady(function() {
				var UserCity = document.getElementById("currentCity");
				var CarCity = document.getElementById("CarCity");
				var self = plus.webview.currentWebview();
				var OtherModular=document.getElementById("OtherModular");
				localStorage.setItem("cityNum", that.cityNum);
				// 多多播报
				that.getLddNoticeList();
				// 获取城市列表
				that.getCity();
				//获取客服
				that.getServicePersonList();
				// 百度地图
				that.locationMap();
				document.addEventListener("resume", function () {
				    that.locationMap();
				}, false);
				mui("#OtherModular").on("tap",".MainModular",function(event){
					event.preventDefault();
					event.stopPropagation();
					var Viewtype=this.getAttribute("OpwenViewType");
					var ViewUrl=this.getAttribute("OpwenViewUrl");
					var Viewid=this.getAttribute("OpwenViewid");
					if(localStorage.getItem("sessionId")){
						if(Viewtype=="2"){
							acore.openWindowByLoad(ViewUrl,Viewid,"fade-in");
						}
						if(Viewtype=="3"){
							var indexView=plus.webview.getLaunchWebview();
							plus.runtime.openURL('http://www.baidu.com');
						}
						if(Viewtype=="4"){
							mui.toast("企业认证暂未开放!");
							return;
						}
						if(Viewtype=="1"){
							var indexView=plus.webview.getLaunchWebview();
							mui.fire(indexView,"AppendView",{viewid:Viewid})
						}
					}else{
						acore.OpenLoginView();
					}
				},false);
				window.addEventListener("ReloadModular",function(event){
					that.selectedTabsList=JSON.parse(event.detail.ModularList);
					that.AppendModular();
				},false);
				// 轮播图使用
				function getLoopImageReq() {
					var baseUrl = acore.getURL() + "getHotModelList.do?method=doLoopImageReq";
					acore.apiSend("GET", baseUrl, null, getDataSuccess, getDataError);
					function getDataSuccess(e) {
						console.log(JSON.stringify(e))
					}
					function getDataError(e) {
						console.log(JSON.stringify(e))
					}
				}
				function launchAppWeixin() {
					if(plus.os.name == "Android") {
						plus.runtime.launchApplication({
							pname: "com.tencent.mm",
							extra: {
								url: "https://m.taobao.com/#index"
							}
						}, function(e) {
							alert("打开失败:" + e.message);
						});
					} else if(plus.os.name == "iOS") {
						plus.runtime.launchApplication({
							action: "weixin://RnUbAwvEilb1rU9g9yBU"
						}, function(e) {
							alert("打开失败: " + e.message);
						});
					}
				}
				// 首页位置修改
				window.addEventListener("SetCity", function(event) {
					if(that.isCar) {
						CarCity.setAttribute("data-typeid", event.detail.cityno);
						CarCity.innerHTML = event.detail.cityname;
						that.carcityno = event.detail.cityno;
						that.carcityname = event.detail.cityname;
					}else {
						UserCity.setAttribute("data-typeid", event.detail.cityno);
						UserCity.innerHTML = event.detail.cityname;
						localStorage.setItem("cityNum", event.detail.cityno);
					}
				}, false);
				var layer_Box = document.getElementById("layer_Box");
				var OpenMember = document.getElementById("OpenMember");
				layer_Box.addEventListener("tap", function() {
					layer_Box.style.display = "none";
					OpenMember.style.display = "none";
				})
				that.GetUserInfo();
				that.GetPayMode();
			});
			setTimeout(function() {
				var gallery = mui('#sliderBanner');
				gallery.slider({
					interval: 5000 //自动轮播周期，若为0则不自动播放，默认为0；
				});
			}, 10)
			var mySwiper = new Swiper('#noticeList', {
				autoplay: true, //可选选项，自动滑动
				direction: 'vertical',
				autoHeight: true,
				slidesPerView: 1,
				loop: true,
				observer: true,
				allowTouchMove: false,
			})
			var mySwiper = new Swiper('#banner', {
				autoplay: true, //可选选项，自动滑动
				autoHeight: true,
				loop: true,
				pagination: {
					el: '.swiper-pagination',
				},
			})
		},
		methods: {
			hideRedPacket: function() {
				this.isShowRedPacket = false;
			},AppendModular:function(){
				var that=this,ModularLength=0;
				var ModularList=document.getElementById("OtherModular").getElementsByClassName("MainModular");
				for(var item in that.selectedTabsList){
					console.log(that.selectedTabsList[item].miniconUrl);
					ModularList[ModularLength].setAttribute("OpwenViewid",item);
					ModularList[ModularLength].setAttribute("OpwenViewUrl",that.selectedTabsList[item].OpenViewUrl);
					ModularList[ModularLength].setAttribute("OpwenViewType",that.selectedTabsList[item].ViewType);
					ModularList[ModularLength].getElementsByClassName("ModularUrl")[0].innerHTML="<img src="+that.selectedTabsList[item].miniconUrl+" />";
					ModularList[ModularLength].getElementsByClassName("ModularName")[0].innerHTML=that.selectedTabsList[item].title;
					ModularLength++;
				}
			},locationMap:function() {
				var that = this;
				plus.geolocation.getCurrentPosition(translatePoint, function(e) {
					mui.toast("请开启定位");
					that.currentLon = that.longitude;
					that.currentLat = that.latitude;
					localStorage.setItem("baiduDistrict","朝阳区");
					localStorage.setItem("baiduCity","北京");
				},{provider:'baidu',coordsType:"bd09ll"});

				function translatePoint(position) {
					var currentLon = position.coords.longitude;
					var currentLat = position.coords.latitude;
					that.currentLon = currentLon;
					that.currentLat = currentLat;
					that.getMapData();
				}
			},initMap:function() {
				var that = this;
				var markerArr = that.dataMapList;
				plus.geolocation.getCurrentPosition(translatePoint, function(e) {
					
				},{provider:'baidu',coordsType:"bd09ll"});
				function translatePoint(position) {
					localStorage.setItem("baiduDistrict",position.address.district);
					localStorage.setItem("baiduCity",position.address.city);
					localStorage.setItem("baiduProvince",position.address.province);
					var currentLon = position.coords.longitude;
					var currentLat = position.coords.latitude;
					that.currentLon = currentLon;
					that.currentLat = currentLat;
					
					if(currentLat=="5e-324") {
						localStorage.setItem("baiduDistrict","朝阳区");
					    localStorage.setItem("baiduCity","北京");
					}
					
					var gpsPoint = new BMap.Point(currentLon, currentLat);
					BMap.Convertor.translate(gpsPoint, 2, initMap); //坐标转换
				}

				function initMap(point) {
					var container = document.getElementById("container")
					map = new BMap.Map("container", { 
						minZoom : 4,
	                    maxZoom : 14  
					}); //创建地图 
					map.centerAndZoom(point, 4);
					var myIcon = new BMap.Icon("../../images/map_mark_flag.png", new BMap.Size(24, 36),{
					    anchor: new BMap.Size(12, 34)
					});
					var marker = new BMap.Marker(point, {
						icon: myIcon
					});
					map.addOverlay(marker);
					
					var arrayMarkers = []; 
					for(var i=0;i<markerArr.length;i++) {
						var myIconFriends = new BMap.Icon("http://123.206.104.151:8089"+markerArr[i].logourl, new BMap.Size(37, 37),{
						    anchor: new BMap.Size(17, 35)
						});
						feiendsPoint = new BMap.Point(markerArr[i].longitude, markerArr[i].latitude);
						arrayMarkers[i] = feiendsPoint;
						marker = new BMap.Marker(feiendsPoint, {
							icon: myIconFriends
						});
						marker.reqid = markerArr[i].reqid;
						map.addOverlay(marker);
						
						marker.addEventListener("click",function(e) {
					    	var params = {
					    		"reqid":  e.target.reqid
					    	};
					    	acore.openWindowByLoad('../lszj/station_details.html', 'station_details', 'slide-in-right',params);
					    });
					}
//					map.setViewport(arrayMarkers);
					
					map.addEventListener("dragend", function (e) {
						console.log("当前位置：" +map.getCenter().lng + "," + map.getCenter().lat);
						that.currentLat = map.getCenter().lat,
					    that.currentLon = map.getCenter().lng,
					    that.page = that.page+1;
						that.getMapData();
			        });
				}
			},
			goApplyLeader:function() {
				var that = this;
				acore.openWindowByLoad("../lszj/departmentTypeList.html", "departmentTypeList", "fade-in",null);
			},nearbyFoodsBusinuss:function() {
				var that = this;
				acore.openWindowByLoad("../lszj/nearby_foods_businuss.html", "nearby_foods_businuss", "fade-in",null);
			},
			relativeNetwork:function() {
				var that = this;
				acore.openWindowByLoad("../lszj/relative_network_map.html", "relative_network_map", "fade-in",null);
			},
			slectFoodsType:function(id) {
				var that = this;
				if(id==4 || id==5) {
//					acore.openWindowByLoad("../lszj/apply_leader", "apply_leader", "fade-in");
					return false;
				}
				
				if(id==1) {
					that.initMap();
				}
				that.foodsType = id;
			},
			getServicePersonList: function() {
				var that = this;
				var baseUrl = acore.getURL() + "login.do?method=getServicePersonList";
				var params = {
					"sessionid": localStorage.getItem("sessionId")
				}
				acore.apiSend("POST", baseUrl, params, getDataSuccess, getDataError);

				function getDataSuccess(e) {
					if(e.status == 2) {
//						mui.toast(e.results);
//						acore.toLogin();
						return false;
					}
					that.servicePersonList = e.results;
				}

				function getDataError(e) {
					console.log(JSON.stringify(e))
				}
			},
			refreshLoginToken: function() {
				var that = this;
				var baseUrl = acore.getURL() + "login.do?method=refreshLoginToken";
				var params = {
					"sessionid": localStorage.getItem("sessionId")
				}
				acore.apiSend("POST", baseUrl, params, getDataSuccess, getDataError);
				function getDataSuccess(e) {
					if(e.status == 2) {
//						mui.toast(e.results);
//						acore.toLogin();
						return false;
					}
				}
				function getDataError(e) {
					console.log(JSON.stringify(e))
				}
			},getLddNoticeList: function() {
				var that = this;
				var baseUrl = acore.getURL() + "getActivityList.do?method=getLoopList";
				var params = {
					"sessionid": localStorage.getItem("sessionId")
				}
				acore.apiSend("POST", baseUrl, params, getDataSuccess, getDataError);

				function getDataSuccess(e) {
					console.log(JSON.stringify(e))
					that.broadcastList = e.results;
					Object.assign({}, that.dataList);
				}

				function getDataError(e) {
					console.log(JSON.stringify(e))
				}
			},memberSign: function() {
				var that = this;
				var params = {
					"sessionid": localStorage.getItem("sessionId"),
					"city": 1,
					"latitude": that.latitude,
					"longitude": that.longitude
				}
				var baseUrl = acore.getURL() + "getActivityList.do?method=memberCheck";
				acore.apiSend("POST", baseUrl, params, getDataSuccess, getDataError);

				function getDataSuccess(e) {
					mui.toast(e.results);
					if(e.status == 2) {
						acore.toLogin();
						return false;
					}
				}

				function getDataError(e) {
					mui.toast(e.results);
				}
			},jumpTabsList: function(pageId) {
				var that = this;
				console.log(pageId)
				if(pageId == "many") {
					acore.openWindowByLoad("./tabsLists.html", "tabsLists", "fade-in");
					return false;
				}
				if(pageId == "credibility_qcc") {
					plus.runtime.openURL("https://m.qichacha.com/");
					return false;
				}
				if(pageId == "shortcutKey_baidu") {
					plus.runtime.openURL("https://www.baidu.com/");
					return false;
				}
				if(pageId == "shortcutKey_baidu") {
					plus.runtime.openURL("https://www.baidu.com/");
					return false;
				}
				if(pageId == "shortcutKey_wechat") {
					var btnArray = ['否', '是'];
					mui.confirm('是否打开微信', '温馨提示', btnArray, function(e) {
						if(e.index == 1) {
							launchAppWeixin();
						} else {
							mui.toast('您取消了跳转微信');
						}
					})

					function launchAppWeixin() {
						if(plus.os.name == "Android") {
							plus.runtime.launchApplication({
								pname: "com.tencent.mm",
								extra: {
									url: "https://m.taobao.com/#index"
								}
							}, function(e) {
								alert("打开失败:" + e.message);
							});
						} else if(plus.os.name == "iOS") {
							plus.runtime.launchApplication({
								action: "weixin://RnUbAwvEilb1rU9g9yBU"
							}, function(e) {
								alert("打开失败: " + e.message);
							});
						}
					}
					return false;
				}

				if(pageId == "credibility_qyrz") {
					mui.toast("该功能暂未开放");
					return false;
				}
				
				if(pageId == "shortcutKey_kf") {
					that.isShowService = !that.isShowService;
					return false;
				}
				acore.openWindowByLoad("../menu/" + pageId + ".html", pageId, "fade-in");
			},
			hideSevicePage: function() {
				var that = this;
				that.isShowService = !that.isShowService;
			},
			jumpMwmberChat: function(items) {
				acore.openWindowByLoad("../oilCicle/chatMenberWindow.html", "chatMenberWindow", "fade-in", {
					"qitem": items
				});
			},jumpSearchPage: function() {
				acore.openWindowByLoad("./search.html", "search", "fade-in");
			},openWeixin: function() {

			},selectCity: function() {
				var that = this;
				that.isCar = false;
				acore.openWindowByLoad("./CityList.html", "CityList", "fade-in", {
					City: JSON.stringify(that.CityList)
				});
			},
			carSelectCity: function() {
				var that = this;
				that.isCar = true;
				acore.openWindowByLoad("./CityList.html", "CityList", "fade-in", {
					City: JSON.stringify(that.CityList)
				});
			},
			getCity: function() {
				var that = this;
				var param = {
					sessionid: localStorage.getItem("sessionId")
				}
				var url = acore.getURL() + "lddStore.do?method=getCityList";
				acore.apiSend("POST", url, param, function(CityListData) {
					if(CityListData.status == 1) {
						for(var i = 0; i < CityListData.results.length; i++) {
							for(var j = 0; j < CityListData.results[i].cityList.length; j++) {
								that.CityList.push(CityListData.results[i].cityList[j]);
							}
						}
						localStorage.setItem("localCityList", JSON.stringify(CityListData.results));
					} else if(CityListData.status == 2) {
						mui.toast("登录已超时，请重新登录!");
					}
				}, function(ErrorData) {

				});
			},
			dearServce: function() {
				var that = this;
				that.isShowService = !that.isShowService;
			},
			goJzdjPage: function() {
				var that = this;
				acore.openWindowByLoad("./shortcutKey_jzdj.html", "shortcutKey_jzdj", "fade-in");
			},
			goAgriculturalPlatform: function() {
				var that = this;
				acore.openWindowByLoad("./agricultural_platform.html", "agricultural_platform", "fade-in");
			},
			ServiceMain: function() {
				var that = this;
				acore.openWindowByLoad("../oilLife/ServiceMain.html", "agricultural_platform", "fade-in");
			},
			goRroup: function() {
				var indexView=plus.webview.getLaunchWebview();
				mui.fire(indexView,"AppendView",{viewid:"oil_cicle"})
			},
			oilLife: function() {
				var indexView=plus.webview.getLaunchWebview();
				mui.fire(indexView,"AppendView",{viewid:"oil_life"})
			},
			goJcpd: function() {
				var that = this;
				acore.openWindowByLoad("../menu/main_jcpd.html", "main_jcpd", "fade-in");
			},
			getMapData: function() {
				var that = this;
				var baseUrl = acore.getURL() + "lddStore.do?method=doGetAreaLsList";
				var params = {
					"sessionid": localStorage.getItem("sessionId"),
					"latitude": that.currentLat,
					"longitude": that.currentLon,
					"page": that.page,
					"pagenum": 20
				}
				console.log(JSON.stringify(params))
				acore.apiSend("POST", baseUrl, params, getDataSuccess, getDataError);

				function getDataSuccess(e) {
					console.log(JSON.stringify(e));
					that.dataMapList = that.dataMapList.concat(e.results);
					Object.assign({}, that.dataMapList);
					if(that.isFirstInitMap) {
						that.initMap();
						that.isFirstInitMap = false;
					}
				}

				function getDataError(e) {
					mui.toast(e.msg);
				}
			},
			hidePopShadow: function() {
				var that = this;
				that.isShowPop = false;
				that.isShowNewLocation = false;
				that.isShowTrail = false;
				that.isShowCarOwner = false;
				that.isShowTransportationCardInquiry = false;
				that.isShowCheckAreaByVclNo = false;
			},
			newLocation: function() {
				var that = this;
				that.isShowPop = true;
				that.isShowNewLocation = true;
			},
			goNewLocation: function() {
				var that = this;
				if(!that.carNumber) {
					mui.toast("请输入车牌号");
					return false;
				}
				that.isShowPop = false;
				that.isShowNewLocation = false;
				that.bdtype = 1;
				that.getConfigInfo(1);
			},
			trajectoryQuery: function() {
				var that = this;
				that.isShowTrail = true;
				that.isShowPop = true;
//				that.carNumberTrajectory = "";
				laydate.render({ 
				  elem: '#startTime'
				  ,type: 'datetime'
				  ,format: 'yyyy-MM-dd HH:mm:ss' //可任意组合
				});
				
				laydate.render({ 
				  elem: '#endTime'
				  ,type: 'datetime'
				  ,format: 'yyyy-MM-dd HH:mm:ss' //可任意组合
				});
			},
			goTrajectoryQuery: function() {
				var that = this;
				
				if(!that.carNumberTrajectory) {
					mui.toast("请输入车牌号");
					return false;
				}
				if(!$("#startTime").val()) {
					mui.toast("请选择起始时间");
					return false;
				}
				if(!$("#endTime").val()) {
					mui.toast("请选择结束时间");
					return false;
				}
				that.startTime = $("#startTime").val();
				that.endTime = $("#endTime").val();
				that.isShowPop = false;
				that.isShowTrail = false;
				that.bdtype = 2;
				that.getConfigInfo(2);
			},
			carOwnerVerification:function() {
				var that = this;
				that.isShowCarOwner = true;
				that.isShowPop = true;
			},
			gocarOwnerVerification: function() {
				var that = this;
				if(!that.carNumberOwner) {
					mui.toast("请输入车牌号");
					return false;
				}
				if(!that.ownerName) {
					mui.toast("请输入车主名字");
					return false;
				}
				if(!that.ownerPhone) {
					mui.toast("请输入车主电话");
					return false;
				}
				
				that.isShowPop = false;
				that.isShowCarOwner = false;
				that.bdtype = 3;
				that.getConfigInfo(3);
			},
			gocarOwnerVerification3: function() {
				plus.nativeUI.showWaiting(); 
				var that = this;
				var baseUrl = acore.getURL() + "lddStore.do?method=checkOwnerByVclNo";
				var params = {
					"sessionid": localStorage.getItem("sessionId"),
					"uid": localStorage.getItem("userId"),
					"vclN": that.carNumberOwner,
					"ownerName": that.ownerName,
					"ownerPhone": that.ownerPhone
				}
				
				console.log(JSON.stringify(params))
				acore.apiSend("POST", baseUrl, params, getDataSuccess, getDataError);

				function getDataSuccess(e) {
					plus.nativeUI.closeWaiting();
					if(e.status == 2) {
						mui.toast(e.results);
						acore.toLogin();
						return false;
					}
					
					if(e.results.status == 9) {
						that.gocarOwnerVerification3();
						return false;
					}
					
					if(e.status != 1) {
						mui.alert(e.results);
						return false;
					}
					
					if(e.results.status == 0) {
						mui.alert(e.results.result);
					} else {
						mui.alert(e.results.result);
					}
				}

				function getDataError(e) {
					plus.nativeUI.closeWaiting();
					mui.toast(e.msg);
				}
			},
			transportationCardInquiry:function() {
				var that = this;
				that.isShowTransportationCardInquiry = true;
				that.isShowPop = true;
			},
			goTransportationCardInquiry: function() {
				var that = this;
				if(!that.trajectoryQueryvclN) {
					mui.toast("请输入车牌号");
					return false;
				}
				that.isShowPop = false;
				that.isShowTransportationCardInquiry = false;
				that.bdtype = 4;
				that.getConfigInfo(4);
			},
			goTransportationCardInquiry4: function() {
				plus.nativeUI.showWaiting(); 
				var that = this;
				var baseUrl = acore.getURL() + "lddStore.do?method=getQueryRTCNo";
				var params = {
					"sessionid": localStorage.getItem("sessionId"),
					"uid": localStorage.getItem("userId"),
					"vclN": that.trajectoryQueryvclN
				}
				
				console.log(JSON.stringify(params))
				acore.apiSend("POST", baseUrl, params, getDataSuccess, getDataError);

				function getDataSuccess(e) {
					plus.nativeUI.closeWaiting();
					if(e.status == 2) {
						acore.toLogin();
						return false;
					}
					
					if(e.results.status == 9) {
						that.goTransportationCardInquiry4();
						return false;
					}
					
					if(e.status != 1) {
						mui.alert(e.results);
						return false;
					}
					
					if(e.results.status == 0) {
						mui.alert("查询失败");
//						mui.alert(e.results.result);
						return false;
					}
					mui.alert("运输证有效期："+e.results.vdtTm+";运输证号："+e.results.roadTransport);
				}

				function getDataError(e) {
					plus.nativeUI.closeWaiting();
					mui.toast(e.msg);
				}
				
			},
			checkAreaByVclNo:function() {
				var that = this;
				that.isShowCheckAreaByVclNo = true;
				that.isShowPop = true;
			},
			goCheckAreaByVclNo: function() {
				var that = this;
				if(!that.checkAreaByVclNovclN) {
					mui.toast("请输入车牌号");
					return false;
				}
				if(!that.carcityno) {
					mui.toast("请选择城市");
					return false;
				}
				that.isShowPop = false;
				that.isShowCheckAreaByVclNo = false;
				that.bdtype = 5;
				that.getConfigInfo(5);
			},
			goCheckAreaByVclNo4: function() {
				plus.nativeUI.showWaiting(); 
				var that = this;
				var baseUrl = acore.getURL() + "lddStore.do?method=checkAreaByVclNo";
				var params = {
					"sessionid": localStorage.getItem("sessionId"),
					"uid": localStorage.getItem("userId"),
					"vclN": that.checkAreaByVclNovclN,
					"area": that.carcityno
				}
				
				console.log(JSON.stringify(params))
				acore.apiSend("POST", baseUrl, params, getDataSuccess, getDataError);

				function getDataSuccess(e) {
					plus.nativeUI.closeWaiting();
					if(e.status == 2) {
						mui.toast(e.results);
						acore.toLogin();
						return false;
					}
					
					if(e.results.status == 9) {
						mui.toast(e.results);
						that.goCheckAreaByVclNo4();
						return false;
					}
					
					mui.alert(e.results);
				}

				function getDataError(e) {
					plus.nativeUI.closeWaiting();
					mui.toast(e.msg);
				}
				
			},
			getConfigInfo: function(bdtype) {
				var that = this;
				var baseUrl = acore.getURL() + "getHotModelList.do?method=getConfigInfo";
				var params = {
					"sessionid": localStorage.getItem("sessionId"),
				}
				
				console.log(JSON.stringify(params))
				acore.apiSend("POST", baseUrl, params, getDataSuccess, getDataError);

				function getDataSuccess(e) {
					if(e.status == 2) {
						mui.toast(e.results);
						acore.toLogin();
						return false;
					}
					if(e.status != 1) {
						mui.toast(e.results);
						return false;
					}
					if(e.results.cfg_bd_ifneedpay == 0 ) {
						switch(bdtype) {
							case 1:
							    var params = {
									"carNumber": that.carNumber
								}
								acore.openWindowByLoad("../navigation/current_location.html", "current_location", "fade-in",params);
							    break;
							case 2:
							    var params = {
									"carNumber": that.carNumberTrajectory,
									"startTime": that.startTime,
									"endTime": that.endTime,
								}
								acore.openWindowByLoad("../navigation/trajectory_query.html", "trajectory_query", "fade-in",params);
							    break;
							case 3:
							    that.gocarOwnerVerification3();
							    break;
							case 4:
							    that.goTransportationCardInquiry4();
							    break;
							case 5:
							    that.goCheckAreaByVclNo4();
							    break;
						}
					} else {
						var amount;
						switch(bdtype) {
							case 1:
							    amount = e.results.cfg_bd_weizhifee;
							    break;
							case 2:
							    amount = e.results.cfg_bd_guijifee;
							    break;
							case 3:
							    amount = e.results.cfg_bd_chezhufee;
							    break;
							case 4:
							    amount = e.results.cfg_bd_yushuzhengfee;
							    break;
							case 5:
							    amount = e.results.cfg_bd_taopaichefee;
							    break;
						}
						that.createTicket(amount,bdtype);
					}
				}

				function getDataError(e) {
					mui.toast(e.msg);
				}
				
			},
			createTicket: function(amount,bdtype) {
				var that = this;
				var baseUrl = acore.getURL() + "login.do?method=createTicket";
				var params = {
					"sessionid": localStorage.getItem("sessionId"),
					"city":  localStorage.getItem("loginCityId"), //暂时写固定值
					"ttype": 10,
					"amount": amount,
					"uid": localStorage.getItem("userId"),
					"bdtype": bdtype,
				}
				
				console.log(JSON.stringify(params))
				acore.apiSend("POST", baseUrl, params, getDataSuccess, getDataError);

				function getDataSuccess(e) {
					if(e.status == 2) {
						acore.toLogin();
						return false;
					}
					if(e.status != 1) {
						return false;
					}
					that.PayOrderInfo = e.results;
					var layer_Box = document.getElementById("layer_Box");
			    	var OpenMember = document.getElementById("OpenMember");
					layer_Box.style.display = "block";
					OpenMember.style.display = "block";
				}

				function getDataError(e) {
					mui.toast(e.msg);
				}
				
			},
			GetUserInfo: function() {
				var self = this;
				var param = {
					sessionid: localStorage.getItem("sessionId"),
					uid: localStorage.getItem("userId")
				}
				var url = acore.getURL() + "login.do?method=doGetAccountInfo";
				acore.apiSend("POST", url, param, function(UserInfoData) {
					var MyView = plus.webview.getWebviewById("my_center");
					if(UserInfoData.status == 1) {
						UserInfo = UserInfoData.results;
						self.UserMoney = "余额（" + UserInfo.cash + "元）";
					} else if(UserInfoData.status == 2) {
						mui.toast("登录已超时，请重新登录!");
						acore.OpenLoginView();
					} else {
						mui.toast(UserInfoData.results);
					}
				}, function(ErrorData) {
					nativeUI.errorMSG("请求失败，请稍候再试!");
				});
			},
			GetPayMode: function() {
				var self = this;
				plus.payment.getChannels(function(Data) {
					console.log(JSON.stringify(Data));
					self.PayMode = {};
					for(var i in Data) {
						self.PayMode[Data[i].id] = Data[i];
					}
				}, function(Error) {
					mui.toast("获取支付方式失败");
				})
			},
			OrderCashPay: function() {
				var self = this;
				var param = {
					sessionid: localStorage.getItem("sessionId"),
					tid: self.PayOrderInfo.tid,
					usecash: self.PayOrderInfo.amount,
					paytype: self.OrderType
				}
				console.log(JSON.stringify(param))
				var url = acore.getURL() + "login.do?method=useAccountCash";
				acore.apiSend("post", url, param, function(Data) {
					if(Data.status == 1) {
						mui.toast("支付完成！");
						var layer_Box = document.getElementById("layer_Box");
				    	var OpenMember = document.getElementById("OpenMember");
						layer_Box.style.display = "none";
						OpenMember.style.display = "none";
						switch(self.bdtype) {
							case 1:
							    var params = {
									"carNumber": self.carNumber
								}
								acore.openWindowByLoad("../navigation/current_location.html", "current_location", "fade-in",params);
							    break;
							case 2:
							    var params = {
									"carNumber": self.carNumberTrajectory,
									"startTime": self.startTime,
									"endTime": self.endTime,
								}
								acore.openWindowByLoad("../navigation/trajectory_query.html", "trajectory_query", "fade-in",params);
							    break;
							case 3:
							    self.gocarOwnerVerification3();
							    break;
							case 4:
							    self.goTransportationCardInquiry4();
							    break;
							case 5:
							    self.goCheckAreaByVclNo4();
							    break;
						}
						self.GetUserInfo();
					} else if(Data.status == 2) {
						mui.toast("登录已超时，请重新登录!");
						acore.OpenLoginView();
					} else {
						mui.toast(Data.results);
					}
				}, function(Errordata) {
					nativeUI.errorMSG("请求失败，请稍后再试...");
				})
			},
			GetAliInfo: function() {
				var self = this;
				var xhr = new XMLHttpRequest();
				xhr.onreadystatechange = function() {
					switch(xhr.readyState) {
						case 4:
							if(xhr.status == 200) {
								var zhifuurl2 = JSON.parse(xhr.responseText).order;
								self.OpenPay(zhifuurl2);
							} else {
								console.log(xhr.responseText);
								mui.toast('获取订单信息失败！');
							}
							break;
						default:
							break;
					}
				}
				var url = "https://api.liangdodo.com/Ldd_Service1/webpay_newversion.jsp?WIDout_trade_no=" + self.PayOrderInfo.tid + "&WIDsubject=订单支付&WIDtotal_amount=" + self.PayOrderInfo.amount + "&WIDbody=商城商品购买";
				xhr.open('POST', url);
				xhr.send();
			},
			OpenPay: function(orderInfo) {
				console.log(orderInfo);
				var self = this;
				plus.payment.request(self.PayMode["alipay"], orderInfo, function(Data) {
					mui.toast("支付成功！");
					var layer_Box = document.getElementById("layer_Box");
			    	var OpenMember = document.getElementById("OpenMember");
					layer_Box.style.display = "none";
					OpenMember.style.display = "none";
					switch(that.bdtype) {
						case 1:
					        var params = {
								"carNumber": that.carNumber
							}
							acore.openWindowByLoad("../navigation/current_location.html", "current_location", "fade-in",params);
						    break;
						case 2:
						    var params = {
								"carNumber": that.carNumberTrajectory,
								"startTime": that.startTime,
								"endTime": that.endTime,
							}
							acore.openWindowByLoad("../navigation/trajectory_query.html", "trajectory_query", "fade-in",params);
						    break;
						case 3:
						    that.gocarOwnerVerification3();
						    break;
						case 4:
						    that.goTransportationCardInquiry4();
						    break;
						case 5:
						    that.goCheckAreaByVclNo4();
						    break;
					}
					self.GetUserInfo();
				}, function(Error) {
					console.log(JSON.stringify(Error))
					mui.toast("支付失败");
				})
			},
			confirm: function(data) {
				var that = this;
                var layer_Box = document.getElementById("layer_Box");
		    	var OpenMember = document.getElementById("OpenMember");
				layer_Box.style.display="block";
				OpenMember.style.display="block";
				that.fastSendReq();
			},
		},
		filters: {
			dataReplace: function(value) {
				return false;
			}
		}
	})
})
